package com.spring.bean.lifecycle;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Lifecycle {
    private String content;

    public void setContent(String content) {
        this.content = content;
    }

    // 初始化后节点的监控方法
    @PostConstruct
    public void init() {
        System.out.println("Bean 初始化后，调用init()方法");
    }

    // 销毁前节点的监控方法
    @PreDestroy
    public void destroy() {
        System.out.println("Bean 销毁前，调用destroy()方法");
    }

    // 输出属性值
    public void print() {
        System.out.println("输出属性值：" + content);

    }
}
